using ODT.Common.ExtensionMethods;
using ODT.Intellisense.Core;

namespace ODT.Intellisense.Services
{
	internal sealed class WordProcessingService : IWordProcessingService
	{
		public string RemoveNumberBetweenBrackets(string word)
		{
			word.ThrowArgumentNullException("word");
			if (word.Contains("[") && word.Contains("]"))
			{
				return RemoveNumberBetweenBrackets(word, '[', ']');
			}
			if (word.Contains("(") && word.Contains(")"))
			{
				return RemoveNumberBetweenBrackets(word, '(', ')');
			}
			return word;
		}

		private string RemoveNumberBetweenBrackets(string word, char bracketCharOpen, char bracketCharClose)
		{
			string text = word;
			if (text.Contains(bracketCharOpen.ToString()))
			{
				int num = text.IndexOf(bracketCharOpen);
				int num2 = text.IndexOf(bracketCharClose);
				if (num2 - num > 1)
				{
					text = text.Remove(num + 1, num2 - num - 1);
				}
			}
			return text;
		}
	}
}
